package beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="subcaracteristica")
public class Subcaracteristica {
	@Id
	private SubcaracteristicaPK subcaracteristicaPK;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumns(value={@JoinColumn(name="iter_numero", insertable=false, updatable=false),
			@JoinColumn(name="proj_cod", insertable=false, updatable=false)})
	private Iteracao iteracao;
	
	@ManyToOne
	@JoinColumn(name="tiposubcar_cod", insertable=false, updatable=false)
	private TipoSubcaracteristica tipoSubcaracteristica;
	
	@Column(name="subcar_peso")
	private Integer peso;
	
	@Column(name="subcar_pontuacao_esperada")
	private Integer pontuacaoEsperada;
	
	public SubcaracteristicaPK getSubcaracteristicaPK() {
		return subcaracteristicaPK;
	}

	public void setSubcaracteristicaPK(SubcaracteristicaPK subcaracteristicaPK) {
		this.subcaracteristicaPK = subcaracteristicaPK;
	}

	public TipoSubcaracteristica getTipoSubcaracteristica() {
		return tipoSubcaracteristica;
	}

	public void setTipoSubcaracteristica(TipoSubcaracteristica tipoSubcaracteristica) {
		if(subcaracteristicaPK == null)
		{
			subcaracteristicaPK = new SubcaracteristicaPK();
		}
		subcaracteristicaPK.setIdTipoSubcaracteristica(tipoSubcaracteristica.getIdTipoSubcaracteristica());
		this.tipoSubcaracteristica = tipoSubcaracteristica;
	}

	public Integer getPeso() {
		return peso;
	}

	public void setPeso(Integer peso) {
		this.peso = peso;
	}

	public Integer getPontuacaoEsperada() {
		return pontuacaoEsperada;
	}

	public void setPontuacaoEsperada(Integer pontuacaoEsperada) {
		this.pontuacaoEsperada = pontuacaoEsperada;
	}

	public Iteracao getIteracao() {
		return iteracao;
	}

	public void setIteracao(Iteracao iteracao) {
		if(subcaracteristicaPK == null)
		{
			subcaracteristicaPK = new SubcaracteristicaPK();
		}
		subcaracteristicaPK.setIdProjeto(iteracao.getIteracaoPK().getIdProjeto());
		subcaracteristicaPK.setIterNumero(iteracao.getIteracaoPK().getIterNumero());
		this.iteracao = iteracao;
	}
}
